function [eqmin] = fractionateGarnet(liquidComp, FeMgKd, SiMgKd)
% assume 2 Als per formula unit no matter what, also 4 wt% CaO no matter what
 
MW = [60.085 79.899	101.961	151.9902	71.846	70.9374	40.311	56.079	61.979	94.203	283.89]; % see matlab guide in excel spreadsheet
%     SiO2    TiO2    Al2O3   Cr2O3       FeO     MnO     MgO     CaO    Na2O    K2O    P2O5
%      1        2       3       4           5       6       7       8     9

liquidComp_moles = liquidComp./MW;
liquidComp_moles = 100*liquidComp_moles/nansum(liquidComp_moles); %%normalizes the molar liquid composition, unneccessary step

% use molar weights and Kds to calculate ratios of elements in mineral
    
    FeMgliq = liquidComp_moles(5)/liquidComp_moles(7);
    SiMgliq = liquidComp_moles(1)/liquidComp_moles(7);

    FeMgmin = FeMgKd*FeMgliq;
    SiMgmin = SiMgKd*SiMgliq;
    

    M_eqmin(1) = 3;
    
    Mg = SiMgmin*M_eqmin(1);
    Fe =  FeMgmin*Mg;
    
    M_eqmin(2) = 0;
    M_eqmin(3) = 1;
    M_eqmin(4) = 0;
    M_eqmin(5) = 3*Fe/(Fe+Mg);
    M_eqmin(6) = 0;
    M_eqmin(7) = 3*Mg/(Fe+Mg);
    M_eqmin(8) = 0.30;
    M_eqmin(9) = 0;
    M_eqmin(10) = 0;
    M_eqmin(11) = 0;

    eqmin = M_eqmin.*MW;                % this is the bulk comosition of equilibrium olivine
    eqmin = eqmin./(0.01*nansum(eqmin));   % renormalized and in wt%
end
        



    
    
    



 